#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../src/thread.h"

void *routine(void *arg){

  char *tmp1 = arg;
  char *buffer = malloc(strlen(arg)+1);
  printf("Thread %d\n", thread_self());
  free(buffer);
  buffer = tmp1;
  printf("Message \"%s\" alloué en mémoire\n[%d o] réservé(s)\n", buffer, strlen(arg)+1);
  thread_exit(arg);
  return NULL;
}

int main(int argc, char **argv){
       
  char *tmp = "Thread test";
  int err;
  void *retval;
  thread_t thread;
  err = thread_create(&thread, &routine, tmp);
  err = thread_join(thread, &retval);
    
  return EXIT_SUCCESS;

}
